{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>用户订单列表</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">
                        <form id="layuiForm">
                            <div class="col-sm-2">
                                <div class="input-group" >
                                    <select name="order_status"  class="form-control m-b search">
                                        <option value="0">全部</option>
                                        <option value="1">未支付</option>
                                        <option value="2">支付成功未确认</option>
                                        <option value="3">是已确认未收货</option>
                                        <option value="4">已完成</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-2">
                                <div class="input-group" >
                                    <select name="order_type" class="form-control m-b search">
                                        <option value="0">全部</option>
                                        <option value="1">支付宝</option>
                                        <option value="2">微信</option>
                                        <option value="3">余额</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="input-group" >
                                    <input type="text"  name="start" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="下单开始日期"/>
                                    <span class="input-group-addon">到</span>
                                    <input type="text"  name="end" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="下单结束日期"/>
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="input-group" >
                                    <input type="text" id="key" class="form-control search" name="key" value="" placeholder="用户"/>
                                    <span class="input-group-btn">
                                        <a  class="btn btn-primary layuiBtn" data-type="reload"><i class="fa fa-search"></i> 搜索</a>
                                    </span>
                                </div>
                            </div>
                        </form>

                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("yhorder/index")}'
            , page: true
            , even: false //开启隔行背景
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            // ,width:100
            , cellMinWidth: 80
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , text: {
                none: '暂无数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            }
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left',}
                , {type:'numbers', width: 60, title: '序号'}
                , {field: 'order_number', width: 230, title: '订单号', align: 'center'}
                , {field: 'order_num', width: 130, title: '商品数量', align: 'center'}
                , {field: 'order_address', width: 130, title: '收货地址', align: 'center'}
                , {field: 'order_address_phone', width: 130, title: '收货人电话', align: 'center'}
                , {field: 'user_username', width: 130, title: '收货人', align: 'center'}
                , {field: 'order_user_pay', width: 130, title: '金额', align: 'center'}
                , {field: 'order_time', width: 220, title: '下单时间', align: 'center'}
                , {field: 'order_paytime', width: 230, title: '付款时间', align: 'center'}
                , {field: 'order_type', width: 130, title: '支付类型', align: 'center',templet:"#order_type"}
                , {field: 'order_status', width: 130, title: '订单状态', align: 'center',templet:"#order_status"}
                , {fixed: 'right', width: 200, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $.each(res.data,function(index,item){
                    $('#view_'+item['order_id']).viewer({
                        url: 'data-original',
                    });
                });
            }
        });

        //搜索表格重载
        var $ = layui.$, active = {
            reload: function () {
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where:$('#layuiForm').parseForm()
                });
            }

        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>
<!--操作模板-->
<!--操作模板-->
<script type="text/html" id="opeBar">
    <a href="javascript:location.href = '{:url('detail')}?id={{d.order_id}}';" class="btn btn-danger btn-outline btn-xs"><i class="fa fa-paste"></i>订单商品详情</a>
</script>
<script type="text/html" id="order_type">
    {{# if(d.order_type == 1){ }}
    <span style="color:darkslategray">支付宝</span>
    {{# } else if(d.order_type == 2){}}
    <span style="color:blueviolet">微信</span>
    {{# } else {}}
    <span style="color:midnightblue">余额</span>
    {{# } }}
</script>
<script type="text/html" id="order_status">
    {{# if(d.order_status == 1){ }}
    <span style="color:black">未支付</span>
    {{# } else if(d.order_status == 2){}}
    <span style="color:black">支付成功未确认</span>
    {{# } else if(d.order_status == 3){}}
    <span style="color:black">是已确认未收货</span>
    {{# } else {}}
    <span style="color:black">已完成</span>
    {{# } }}
</script>
</body>
</html>